﻿/* logo */
$(function(){
	$(".logo").mouseover(function(){
		$("#logo img").attr("src","images/logo.png");
	});
	$(".logo").mouseout(function(){
		$("#logo img").attr("src","images/logo1.png");
	});
});


/* 搜索 */
$(function(){
	$(".search1").focus(function(){
		$(this).animate({width:"199px"},200).css("border","solid 1px #fdd57b");
	});
	$(".search1").blur(function(){
		$(this).animate({width:"170px"},200).css("border","solid 1px #e8e8e9");
	});
});

$(function(){
	$(".search2").mouseover(function(){
		$(".search-box input").attr("src","images/search3.gif");
	});
	$(".search2").mouseout(function(){
		$(".search-box input").attr("src","images/search2.gif");
	});
});


/* 菜单栏 */
$(function(){
	$("#home").mouseover(function(){
		$("#home img").attr("src","images/home1.gif");
	});
	$("#home").mouseout(function(){
		$("#home img").attr("src","images/home2.gif");
	});
	$("#news").mouseover(function(){
		$("#news img").attr("src","images/news1.gif");
	});
	$("#news").mouseout(function(){
		$("#news img").attr("src","images/news2.gif");
	});
	$("#amusement").mouseover(function(){
		$("#amusement img").attr("src","images/amusement1.gif");
	});
	$("#amusement").mouseout(function(){
		$("#amusement img").attr("src","images/amusement2.gif");
	});
	$("#sports").mouseover(function(){
		$("#sports img").attr("src","images/sports1.gif");
	});
	$("#sports").mouseout(function(){
		$("#sports img").attr("src","images/sports2.gif");
	});
	$("#money").mouseover(function(){
		$("#money img").attr("src","images/money1.gif");
	});
	$("#money").mouseout(function(){
		$("#money img").attr("src","images/money2.gif");
	});
});


/* 右边提示和分享按钮显隐 */


$(function(){
	$(".content-wall").mouseover(function(){
	
		$(this).addClass("content-wallhover");
		
		$(this).find("#renren").attr("src","images/renrenhover.png");
		$(this).find("#tencent").attr("src","images/tencenthover.png");
		$(this).find("#sina").attr("src","images/sinahover.png");
		
	}).mouseout(function(){
	
		$(this).removeClass("content-wallhover");
		
		$(this).find("#renren").attr("src","images/renren.png");
		$(this).find("#tencent").attr("src","images/tencent.png");
		$(this).find("#sina").attr("src","images/sina.png");
	});
});


/* 支持按钮 */
$(function(){

	$(".support").mouseover(function(){
		$(this).removeClass("support-bg").addClass("support-bghover");
		
		$(this).find(".support-wold").removeClass("support-wold").addClass("support-woldhover");
		
		$(this).find(".support-num").removeClass("support-num").addClass("support-numhover");
		
	}).mouseout(function(){
		$(this).removeClass("support-bghover").addClass("support-bg");
		
		$(this).find(".support-woldhover").removeClass("support-woldhover").addClass("support-wold");
		
		$(this).find(".support-numhover").removeClass("support-numhover").addClass("support-num");
		
	});
	
})

$(function(){
	$(".support").click(function(){
		$(this).css({'background':'url("images/supportclick.gif")'});
		$(this).find(".support-woldhover").text("已支持").css("color","#ccc");
		$(this).find(".support-numhover").css("color","#ccc");
	})
});

/* 评论框 */

$(function(){
	$(".comment").focus(function(){
		$(this).animate({height:"80px"},200).css("border","solid 1px #fdd57b").css("border-top","none");
		
		$(this).parent(".comment-wall").css("background-position","0 7px");
		
		$(this).charCount();
		
		$(this).nextAll(".submit").removeClass("none");
		
		$(this).nextAll(".comment-notic").addClass("none");
		
	});
	$(".comment").blur(function(){
		$(this).animate({height:"25px"},200).css("border","solid 1px #e2e2e2").css("border-top","none");
		
		$(this).parent(".comment-wall").css("background-position","0 -16px");
		
		$(".counter").fadeTo("1","0");
		
		$(this).nextAll(".submit").addClass("none");
	});
});

/* 发表按钮 */
$(function(){
	$(".submit").mouseover(function(){
		$(this).attr("src","images/submitclick.gif");
	}).mouseout(function(){
		$(this).attr("src","images/submit.gif");
	});
});

/* 评论框自动伸缩 */
  var InitHeight = 20;
  function AutoExpand(e) {
    var HideTextarea = document.getElementById("__hidetextarea");
    if (!HideTextarea) {
      HideTextarea = document.createElement("textarea");
      HideTextarea.id = "__hidetextarea";
      HideTextarea.style.borderWidth = 0;
      document.body.appendChild(HideTextarea);
    }
    HideTextarea.value = e.value;
    HideTextarea.style.height = "0px";
    HideTextarea.style.overflow = "hidden";
    var x = HideTextarea.scrollHeight + "必须先计算下scrollHeight的值，否则，scrollHeight 的值将固定？";
    delete x;
    e.style.height = Math.max(Math.max(InitHeight,20), HideTextarea.scrollHeight) + "px";
  }
  function MaxMe(o) {
    if (window.navigator.userAgent.indexOf("Firefox") > -1) {
      o.style.height = o.scrollTop + o.scrollHeight + "px";
    }
    else {
      if (o.scrollTop > 0) o.style.height = o.scrollTop + o.scrollHeight + "px";
    }
  }

  function Init() {
    var t1 = document.getElementById("textarea1");
    InitHeight = t1.offsetHeight;

    var textarea = document.getElementById("textarea");
    if (textarea.addEventListener) {    // 非Internet Explorer和Internet Explorer9之后的版本
      textarea.addEventListener("input", OnTextInput, false);
      // Google Chrome 和 Safari
      textarea.addEventListener("textinput", OnTextInput, false);
    }

    if (textarea.attachEvent) { // Internet Explorer 和 Opera
      textarea.attachEvent("onpropertychange", OnTextInput);
    }
  }

  function OnTextInput(evt) {
    o = window.event ? window.event.srcElement : evt.target;
    if (window.navigator.userAgent.indexOf("Firefox") > -1) {
      o.style.height = o.scrollTop + o.scrollHeight + "px";
    }
    else {
      if (o.scrollTop > 0) o.style.height = o.scrollTop + o.scrollHeight + "px";
    }
  }
  window.onload = Init;

/* ==============comment页面================   */

/* 立即评论 */
$(function(){
	$(".immediately-comment").mouseover(function(){
		$(this).attr("src","images/immediately-commenthover.gif");
	}).mouseout(function(){
		$(this).attr("src","images/immediately-comment.gif");
	});
});

/* 右边高亮提示及分享 */
$(function(){
	$(".c-content-wall").mouseover(function(){
	
		$(this).css("border-right","solid 1px #fdd57b");
		
		$(this).find("#renren").attr("src","images/renrenhover.png");
		$(this).find("#tencent").attr("src","images/tencenthover.png");
		$(this).find("#sina").attr("src","images/sinahover.png");
		
	}).mouseout(function(){
	
		$(this).css("border-right","solid 1px #fff");
		
		$(this).find("#renren").attr("src","images/renren.png");
		$(this).find("#tencent").attr("src","images/tencent.png");
		$(this).find("#sina").attr("src","images/sina.png");
	});
});
/* 支持按钮 */
$(function(){
	$(".c-support").mouseover(function(){
		$(this).css("color","#fff").css("background-color","#7db9cf");
	}).mouseout(function(){
		$(this).css("color","#7db9cf").css("background-color","#fff");
	});
});

/* 评论框   */
	
$(function(){
	$(".c-comment").charCount();
});
$(function(){
	$(".c-comment").focus(function(){
		$(this).css("border","solid 1px #fdd57b");			
	});
	$(".c-comment").blur(function(){
		$(this).css("border","solid 1px #e2e2e2");

	});
});


/* LEFT转换  */


$(function(){
$('.sideNav').unbind('click');
$('.left').eq(0).siblings().hide();
$('.right').show();
$('.sideNav').click(function(event){
	var index = 0;
	//alert("123");
	index = $('.sideNav').index(this);
	$('.left').hide();
	$('.left').eq(index).fadeIn(400);
	event.preventDefault();
});
});

